import { reactive, ref } from "vue";

export default function InitHook() {
  const formState = reactive<Partial<MyApproval.CheckProblemType>>({
    approvalList: []
  });
  const loading = ref<boolean>(false);
  const formRef = ref<any>(null);
  const getColor = (e: number): string => {
    const colorMap: { [key: number]: string } = {
      1: "red",
      2: "green",
      4: "green",
      3: "blue",
      0: "blue"
    };

    return colorMap[e] ?? "blue";
  };
  const isConfirmationHandle = (e: number): number => {
    const mapping: { [key: number]: number } = {
      0: 3,
      1: 4,
      2: 1
    };

    return mapping[e] ?? 10;
  };
  const getState = new Map([
    [0, "待审批"],
    [1, "审批驳回"],
    [2, "审批通过"],
    [3, "待确认"],
    [4, "已确认"],
    [10, "未知"]
  ]);

  return { formState, loading, formRef, getColor, isConfirmationHandle, getState };
}
